﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyX.Core;

namespace LearningEnglish.Models
{
    public class WordBook : XEntity
    {
        public WordBook(Guid id) : base(id) { }

        public WordBook(Guid createUserID, string name, string message, Guid imgID)
        {
            Words = new List<string>();
            Update(new WordBookCreated() { CreateUserID = createUserID, Name = name, Message = message, ImgID = imgID });
        }

        public void Add(string word)
        {
            Update(new WordBookWordAdded() { Word = word });
        }        

        public void Do(WordBookCreated e)
        {

        }

        public void Do(WordBookWordAdded e)
        {
            Words.Add(e.Word);
        }

        public List<string> Words { get; private set; }
    }

    public class WordBookCreated : XEvent
    {
        public string Name { get; set; }
        public string Message { get; set; }
        
        public Guid ImgID { get; set; }

        public Guid CreateUserID { get; set; }

    }

    public class WordBookWordAdded : XEvent
    {
        public string Word { get; set; }
    }

    public class WordBookWordRemoved:XEvent
    {
        public string Word { get; set; }
    }
}